package server.connection;

import general.helperclasses.logger.Logger;
import general.helperclasses.logger.LoggingLevel;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ConnectionHandler {

	private final ThreadGroup pool;
	private final ServerSocket serverSocket;
	private final int port;
	
	public ConnectionHandler(int port) throws IOException
	{
		this.port = port;
		
		this.pool = new ThreadGroup("ClientConnectionGroup");
		
		try {
			this.serverSocket = new ServerSocket(port);
			
			ConnectionReceiver receiver = new ConnectionReceiver(pool, serverSocket);
			receiver.start();
			
		} catch (IOException e) {
			Logger.addEntry(LoggingLevel.SERVE, "Could not start server!\n"+e.toString());
			throw e;
		}
		

	}
}
